﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdministratorHA/Master.Master" AutoEventWireup="true" CodeBehind="frmLoaiHangHoa.aspx.cs" Inherits="WebComputers.AdministratorHA.frmLoaiHangHoa" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div id="page-heading">
        <h1>Loại Hàng Hóa</h1>
    </div>

    <table border="0" style="width:100%;" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
            <th class="topleft"></th>
            <td id="tbl-border-top">&nbsp;</td>
            <th class="topright"></th>
            <th rowspan="3" class="sized">
                <img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
        </tr>
        <tr>
            <td id="tbl-border-left"></td>
            <td>
                <!--  start content-table-inner ...................................................................... START -->
                <div id="content-table-inner">

                    <!--  start table-content  -->
                    <div id="table-content">

                        <table border="0" id="id-form">
                           
                            <tr>
                                <th style="vertical-align:top;">
                                    <asp:Label runat="server" Text="Tên Loại Hàng Hóa :"></asp:Label>
                                </th>
                                <td>
                                    <asp:TextBox runat="server" ID="txtTenLoai" CssClass="input-short input-left" TabIndex="1"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="vldTenLoai_left" runat="server" ControlToValidate="txtTenLoai" CssClass="error-left" ErrorMessage=""></asp:RequiredFieldValidator>
                                    <asp:RequiredFieldValidator ID="vldTenLoai" runat="server" ControlToValidate="txtTenLoai" CssClass="error-inner" ErrorMessage="This field is required."></asp:RequiredFieldValidator>
                                </td>

                            </tr>
                                                        
                            <tr>
                                <th style="vertical-align:top;">
                                    <asp:Label runat="server" Text="Hình Đại Diện :"></asp:Label>
                                </th>
                                <td>
                                    <div>
                                        <asp:FileUpload runat="server" ID="fulHinhDaiDien" CssClass="input-medium input-left" TabIndex="2" ClientIDMode="Static" />
                                    </div>
                                    <div class="bubble-left"></div>
                                    <div class="bubble-inner">JPEG, GIF 5MB max per image</div>
                                    <div class="bubble-right"></div>
                                </td>
                            </tr>

                            <tr>
                                <th style="vertical-align:top;">&nbsp;</th>
                                <td>
                                    <div id="message-red">
                                    <table border="0">
                                        <tr>
                                            <td class="red-left">
                                                <asp:Image runat="server" ID="imgHinhDaiDien" Width="310px" ClientIDMode="Static"/>
                                                <asp:HiddenField runat="server" ID="hdfHinhDaiDien" Value="0" />
                                            </td>
                                            <td class="red-right" style="vertical-align:top;"><a class="close-red" onclick="document.getElementById('ContentPlaceHolder1_hdfHinhDaiDien').value = '0';">
                                                <img src="images/table/icon_close_red.gif" alt="" title="Xóa ảnh" /></a></td>
                                        </tr>
                                    </table>
                                    </div>
                                    
                                </td>
                            </tr>

                            <tr>
                                <th style="vertical-align:top;">
                                    <asp:Label runat="server" Text="Quản trị :"></asp:Label>
                                </th>
                                <td>
                                    <ul class="input-short ul-border">
                                        <li>
                                            <asp:CheckBox runat="server" ID="cbTrangChu" Text="Trang Chủ" TabIndex="3" />
                                        </li>
                                        <li>
                                            <asp:CheckBox runat="server" ID="cbQuanLy" Text="Quản Lý" TabIndex="4" />
                                        </li>
                                    </ul>
                                </td>
                            </tr>
                                                                                    
                            <tr>
                                <th style="vertical-align:top;">
                                    <asp:Label runat="server" Text="Mô tả :"></asp:Label>
                                </th>
                                <td>
                                    <asp:TextBox runat="server" ID="txtMoTa" TextMode="MultiLine" Columns="90" Rows="11" CssClass="input-long" TabIndex="5"></asp:TextBox>
                                </td>
                            </tr>
                            
                             <tr>
                                <th></th>
                                <td>
                                    <asp:HiddenField runat="server" ID="hdfID" Value="-1" />
                                </td>
                            </tr>

                            <tr>
                                <th style="vertical-align:top;">&nbsp;</th>
                                <td>

                                    <asp:Button runat="server" ID="btnLuu" Text="Lưu" CssClass="btn btn-success" OnClick="btnLuu_Click" OnClientClick="Encode();" />
                                    <input type="button" id="btnXoa" value="Xóa" class="btn btn-warning" onclick="reset(); ResetAllField();" />
                                    <input type="button" id="btnHuy" value="Hủy bỏ" class="btn btn-danger" onclick="reset(); ResetAllField();" />
                                </td>
                            </tr>
                        </table>

                        <div class="grid_12" style="width: 100%; margin: 0px;">


                            <div class="bottom-spacing">

                                <!-- Button -->
                                <div class="float-right">
                                    <a href="#" class="button" onclick="return false;">
                                        <span>Thêm mới<img src="images/plus-small.gif" width="12" height="9" alt="New article" /></span>
                                    </a>
                                </div>

                                <!-- Table records filtering -->
                                Filter: 
                                        <select class="input-short">
                                            <option value="1" selected="selected">Select filter</option>
                                            <option value="2">Created last week</option>
                                            <option value="3">Created last month</option>
                                            <option value="4">Edited last week</option>
                                            <option value="5">Edited last month</option>
                                        </select>

                            </div>


                            <!-- Example table -->
                            <div class="module">
                                <h2><span>Bảng Loại Hàng Hóa</span></h2>

                                <div class="module-table-body">
                                    <asp:GridView ID="grvLoaiHangHoa" runat="server" AutoGenerateColumns="False" CellSpacing="-1" CssClass="tablesorter" DataKeyNames="iLoaiHangHoa_ID" GridLines="None" OnRowDeleting="grvLoaiHangHoa_RowDeleting" OnSelectedIndexChanging="grvLoaiHangHoa_SelectedIndexChanging">
                                        <Columns>
                                            <asp:BoundField DataField="STT" HeaderText="STT" />
                                            <asp:BoundField DataField="iLoaiHangHoa_ID" HeaderText="Mã Loại Hàng Hóa" />
                                            <asp:BoundField DataField="sTenLoai" HeaderText="Tên Loại Hàng Hóa" />
                                            <asp:TemplateField HeaderText="Hình Đại Diện">
                                                <ItemTemplate>
                                                    <a href="#" onclick="return false;" class="activePopover" rel="popover" data-content="<img src='<%# Eval("imgPopOver") %>' width='100%'/>" title='<%# Eval("sTenLoai") %>'><%# Eval("sHinhDaiDien") %></a>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CheckBoxField DataField="bTrangChu" HeaderText="Trang Chủ" />
                                            <asp:CheckBoxField DataField="bQuanLy" HeaderText="Quản Lý" />
                                            <asp:CommandField ButtonType="Image" DeleteImageUrl="~/AdministratorHA/images/bin.gif" DeleteText="Xóa" HeaderText="Thao Tác" SelectImageUrl="~/AdministratorHA/images/pencil.gif" SelectText="Sửa" ShowDeleteButton="True" ShowSelectButton="True" />
                                        </Columns>
                                    </asp:GridView>

                                    <div class="pager" id="pager">
                                        <div>
                                            <asp:ImageButton runat="server" ID="btnFirst" ImageUrl="images/arrow-stop-180.gif" CssClass="first" AlternateText="First" CommandName="First" OnCommand="ChangePage" CausesValidation="False" />
                                            <asp:ImageButton ID="btnPrev" runat="server" ImageUrl="images/arrow-180.gif" AlternateText="Prev" CssClass="prev" CommandName="Prev" OnCommand="ChangePage" CausesValidation="False" />

                                            <asp:TextBox ID="txtPageIndex" runat="server" CssClass="pagedisplay input-short align-center" Width="20" Text="1" AutoPostBack="True" OnTextChanged="txtPageIndex_TextChanged"></asp:TextBox>
                                            <asp:Label runat="server" Text="of" Font-Size="Medium"></asp:Label>
                                            <asp:TextBox ID="txtTotalPages" runat="server" CssClass="pagedisplay input-short align-center" Width="20" Text="0" ReadOnly="true"></asp:TextBox>

                                            <asp:ImageButton runat="server" ID="btnNext" ImageUrl="images/arrow.gif" CssClass="next" AlternateText="Next" CommandName="Next" OnCommand="ChangePage" CausesValidation="False" />
                                            <asp:ImageButton runat="server" ID="btnLast" ImageUrl="images/arrow-stop.gif" CssClass="last" AlternateText="Last" CommandName="Last" OnCommand="ChangePage" CausesValidation="False" />
                                            <asp:DropDownList runat="server" ID="ddlPageSize" CssClass="pagesize input-short align-center" AutoPostBack="true" OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged"></asp:DropDownList>
                                            <asp:HiddenField runat="server" ID="hdfPageSize" />

                                        </div>
                                    </div>
                                    <div class="table-apply">
                                        <div>
                                            <span>Apply action to selected:</span>
                                            <select class="input-medium">
                                                <option value="1" selected="selected">Select action</option>
                                                <option value="2">Publish</option>
                                                <option value="3">Unpublish</option>
                                                <option value="4">Delete</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div style="clear: both"></div>
                                </div>
                                <!-- End .module-table-body -->
                            </div>
                            <!-- End .module -->

                        </div>
                        <!-- End .grid_12 -->

                    </div>
                    <!--  end content-table  -->

                </div>
                <!--  end content-table-inner ............................................END  -->
            </td>
            <td id="tbl-border-right"></td>
        </tr>
        <tr>
            <th class="sized bottomleft"></th>
            <td id="tbl-border-bottom">&nbsp;</td>
            <th class="sized bottomright"></th>
        </tr>
    </table>
    
    <script src="js/bootstrap-tooltip.js"></script>
    <script src="js/bootstrap-popover.js"></script>

    <script>
        $(document).ready(function () {
            $("#li-LHH").toggleClass("sub_show");
            $("#div-SanPham").toggleClass("show");
            $("#ul-SanPham").toggleClass("current");
        });
    </script>
    <script>
        $(function () {
            $(".activePopover").popover({ placement: 'right' });
        });
    </script>
    <script>
        $(function () {
            $("#fulHinhDaiDien").bind('change', function () {
                var img = $("#fulHinhDaiDien").val();
                $("#imgHinhDaiDien").attr('src', "../Images/" + img + "?" + Math.random());
                $(".red-right").hide();
            });
        });
        $(document).ready(function () {
            var i = document.getElementById("ContentPlaceHolder1_hdfID").value;
            var txt = $('#ContentPlaceHolder1_txtTenLoai');
            if ($.trim(txt.val()) == '' || txt.val() == null) {
                document.getElementById("imgHinhDaiDien").src = "";
            }            
            if(i == "0")
                document.getElementById("imgHinhDaiDien").src = "";
        });
        $(document).ready(function () {
            var img = document.getElementById("ContentPlaceHolder1_hdfHinhDaiDien").value;
            if (img == "0")
                $(".red-right").hide();
            else
                $(".red-right").show();
        });
    </script>
    <script type="text/javascript">
        function ResetAllField() {
            document.getElementById("ContentPlaceHolder1_txtTenLoai").value = "";
            
            $('#ContentPlaceHolder1_txtMoTa').wysiwyg('clear', "");            
            document.getElementById("ContentPlaceHolder1_cbQuanLy").checked = false;
            document.getElementById("ContentPlaceHolder1_cbTrangChu").checked = false;
            document.getElementById("imgHinhDaiDien").src = "";
            $(".red-right").hide();
            document.getElementById("ContentPlaceHolder1_hdfHinhDaiDien").value = "0";
        }
        window.reset = function () {
            var e = $("#fulHinhDaiDien");
            e.wrap('<form>').closest('form').get(0).reset();
            e.unwrap();
        }
        function Encode() {
            //var z = encodeURI($('#ContentPlaceHolder1_txtMoTa').val());
            var z = $('<div/>').text($('#ContentPlaceHolder1_txtMoTa').val()).html();
            //$('#ContentPlaceHolder1_txtMoTa').wysiwyg('destroy');
            //document.getElementById("ContentPlaceHolder1_txtMoTa").value = z;
            $('#ContentPlaceHolder1_txtMoTa').wysiwyg('setContent', z);            
            //$('#ContentPlaceHolder1_txtMoTa').val('hadz');
            //alert($('#ContentPlaceHolder1_txtMoTa').val());

        }
    </script>
</asp:Content>
